/*
	NGUOI TAO	HUYBDK
	NGAY TAO	13/4/2011

	TRUYEN VAO 2 THAM SO
	1 TENDN
	2 MATKHAU
	OUTPUT: 1 BIEN (RESULT) DE BIET CO DANG NHAP DC KO
	RESULT =1 DANG NHAP THANH CONG
	RESULT =0 DANG NHAP THAT BAI 
*/
IF EXISTS (SELECT * FROM DBO.SYSOBJECTS WHERE NAME='SP_KIEMTRATENDANGNHAP')
BEGIN
	DROP PROC SP_KIEMTRATENDANGNHAP
END
GO
CREATE PROC  SP_KIEMTRATENDANGNHAP
	-- TAT CA THAM SO IN + OUT 
	@TENDN		NVARCHAR(30),
	@MATKHAU	NVARCHAR(30),
	@RESULT		INT OUTPUT
AS
BEGIN
	-- CHUA DOAN LENH XU LY
	IF EXISTS (SELECT * FROM THANHVIEN WHERE TENDN=@TENDN AND MATKHAU=@MATKHAU)
	BEGIN
		SET @RESULT=1
		PRINT 'DANG NHAP THANH CONG'
	END
	ELSE
	BEGIN
		SET @RESULT=0
		PRINT 'DANG NHAP THAT BAI'
	END 
END

/*
DECLARE @TENDN		NVARCHAR(30)
DECLARE	@MATKHAU	NVARCHAR(30
DECLARE @RESULT		INT
SET	@TENDN = 'QUANG'
SET @MATKHAU = '123456'
EXEC SP_KIEMTRATENDANGNHAP @TENDN,@MATKHAU,@RESULT OUTPUT
SELECT @RESULT AS 'RESULT'
*/


/*
DECLARE @RESULT		INT
EXEC SP_KIEMTRATENDANGNHAP 'QUANG','123456',@RESULT OUTPUT
SELECT @RESULT AS 'RESULT'
*/